[#ftl]
  [#--include "../../util.ftl"/--]

  [@define "agile.html.Link"  "agile._Component,agile._Resizable" ]
	category:"Link Component"	
	,widgetName:"Link"
	[#assign templateString][#compress] 		
 		<div class='agileComponent agileLink'>
 			<div data-dojo-attach-point="value" data-dojo-type="dijit/InlineEditBox" width="{style.width}" style="width:{style.width};display:inline">{parameters.value}</div>
 		</div>
	[/#compress][/#assign]
	,templateString:"${templateString?js_string}"	
	,resizeAxis:"x"
	,templateMap:{
		dojo:"<a {html-style} {html-parameters}>{innerWidets}</a>"
		,agile:"<div data-dojo-type='{declaredClass}' data-dojo-props='{style-props}'>{innerWidets}</div>"
	}	
	,attributes:agile.delegate(agile._Component.prototype.attributes,{
		value:lang.mixin({},agile.TextMetadata,{
			label:"i18n_display_text"//,_ignore:true
//			,isRenderAsInnerHtml:function(widget,sourceType){
//				return sourceType == "dojo";
//			}
			,ignore:function(ownerWidget,sourceType){ return sourceType=!"agile";}
			,onValueChange:function(/*widget*/widget,/*String*/name,/*Object*/value){	
				widget.value.reset1("value",value);
				widget.metadata(this.metadataCategory+"."+name,value);
			}
		})	
		,href:lang.mixin({},agile.TextMetadata,{
			label:"i18n_url"
			,onValueChange:function(/*widget*/widget,/*String*/name,/*Object*/value){	
				//widget.href.reset1("value",value);
				widget.metadata(this.metadataCategory+"."+name,value);
			}
		})
		,target:lang.mixin({},agile.ComboMetadata,{
			label:"i18n_target_window"
			,options:agile.i18nMap(["_blank","_top","_self","_parent"],null,true)				
			,onValueChange:function(/*widget*/widget,/*String*/name,/*Object*/value){	
				//widget.target.reset1("value",value);
				widget.metadata(this.metadataCategory+"."+name,value);
			}
		})
	})	
	,initDefaultMetadata:function(){	
		this.metadata("parameters.href","http://beyond-prototype.com");
		this.metadata("parameters.value","beyond-prototype");
		this.metadata("parameters.target","_blank");
		this.metadata("style.width","120px");		
		agile.requireX("dijit.InlineEditBox");
	}
	,init:function(){
//		this.resetInlineEditBox(this.href);
//		this.resetInlineEditBox(this.target);
		this.resetInlineEditBox(this.value);
//		on(this.href,"onChange",this,function(newValue){
//			topic.publish("agile.widget.changed",[this.category,"href",newValue]);
//		},this);
//		on(this.target,"onChange",this,function(newValue){
//			topic.publish("agile.widget.changed",[this.category,"target",newValue]);
//		},this);
		aspect.after(this.value,"onChange",lang.hitch(this,function(newValue){
			topic.publish("agile.widget.changed",this.category,"value",newValue);
		}),true);
	}
	
	,getResizableTargetContainer:function(){				
		return this.domNode;		 
	}
	,onResizeStop:function(marginBox){
		this.inherited(arguments);
		style.set(this.value.domNode,"width",this.metadata("style.width"));
		style.set(this.value.domNode,"height",this.metadata("style.height"));		
	}
	,getInnerWidgetTemplate:function(params){
		return this.metadata("parameters.value");
	}
//	,toHtml:function(params){
//		if(sourceType == "dojo"){
//			//var indent = this.indent(indentCount);
//			var styleStr = this.serializeStyle2(sourceType).replace("style:","style=");
//			return lang.replace(this.templateMap[sourceType],{style:styleStr,parameters:this.serializeParameters2("dojo","html"),innerWidets:this.metadata("parameters.value")});	
//		}else{
//			return this.inherited(arguments);
//		}
//	}
[/@]
